package com.jd.mapper;

import com.jd.entity.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {
    @Select("select * from book")
    List<Book> selectAllBooks();

    @Select("select * from book where bookId = #{id}")
    Book selectBookById(int id);

    @Select("select * from book where bookName like '%${bookName}%'")
    List<Book> selectBookByName(String bookName);

    @Delete("delete from book where bookId = #{id}")
    int deleteBookById(int id);

    @Insert("insert into book (bookName, bookAuthor, bookPrice, bookPic, bookPublisher) VALUES (#{bookName},#{bookAuthor},#{bookPrice},#{bookPic},#{bookPublisher})")
    int insertBook(Book book);

    @Update("update book set bookName = #{bookName},bookAuthor = #{bookAuthor},bookPrice = #{bookPrice},bookPic = #{bookPic},bookPublisher = #{bookPublisher} where bookId = #{bookId}")
    int updateBook(Book book);


}
